package com.hsy.linemoney.modules.home.fragment;

import android.os.Bundle;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.hsy.linemoney.R;
import com.hsy.linemoney.modules.common.CommonBaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/7/11.
 */
public class Home1RateListFragment extends CommonBaseFragment {
    private ListView listView;
    private LayoutInflater inflater;
    private List<String> listData = new ArrayList<>();
    private Adapter adapter;

    @Override
    protected int getFragmentLayout() {
        return R.layout.fragment_home_1_list;
    }

    @Override
    protected void initView(View view, Bundle bundle) {
        inflater = LayoutInflater.from(getAttchedActivity());

        listView = F(R.id.list1);
        listData.clear();
        for (int i = 0; i < 12; i++) {
            listData.add("即时服务" + i);
        }
        adapter = new Adapter();
        listView.setAdapter(adapter);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onHandleMessage(Message message) {

    }

    @Override
    public void onFragmentUpdate() {

    }

    private class Adapter extends BaseAdapter {

        @Override
        public int getCount() {
            return listData.size();
        }

        @Override
        public Object getItem(int position) {
            return listData.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            convertView = inflater.inflate(R.layout.item_home_list, null);
            TextView name = (TextView) convertView.findViewById(R.id.name);
            name.setText(listData.get(position));
            return convertView;
        }
    }

}
